package com.example.howard.xiao7music.ui.adapter.LocalAdapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.howard.xiao7music.R;

import java.util.List;
import java.util.Map;


/**
 * Created by Howard on 2016/10/23.
 */
public class LocalFolderAdapter extends BaseAdapter {

    LayoutInflater inflater;
    List<Map<String, Object>> list;


    public LocalFolderAdapter (Context c,List<Map<String, Object>> folderlist){
        this.inflater = LayoutInflater.from(c);
        this.list=folderlist;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    public View getView(final int position, View convertView,
                        ViewGroup parent) {
        ViewHolder viewHolder;

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.local_folder_item, null);
            viewHolder = new ViewHolder();
            viewHolder.folder_name = (TextView) convertView
                    .findViewById(R.id.folder_name);
            viewHolder.folder_path = (TextView) convertView
                    .findViewById(R.id.folder_path);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.folder_name.setText(list.get(position).get("FOLDERNAME")
                .toString());
        viewHolder.folder_path.setText(list.get(position).get("PATH")
                .toString());

        return convertView;
    }

    class ViewHolder {
        TextView folder_name;
        TextView folder_path;
    }

}
